
// Minimal fallback: if auth.js hasn't bound click handlers,
// make header buttons act as links to account & subscribe pages.
(function(){
  try{
    var hdr = document.querySelector('header');
    if(!hdr) return;
    var findBtn = function(label){
      return Array.from(hdr.querySelectorAll('.ghost,.btn')).find(function(el){
        return (el.textContent||'').trim() === label;
      });
    };
    var loginBtn = findBtn('登录');
    var startBtn = findBtn('开始使用');
    // If they already have a click listener (added by auth.js), don't override
    function hasListener(el){ try{ return !!el._rt_bound; }catch(e){ return false; } }
    function bind(el, handler){
      if(!el) return;
      if(hasListener(el)) return;
      el.addEventListener('click', function(e){
        // If auth.js added a modal opener, let it run
        if(document.getElementById('auth-modal')) return;
        e.preventDefault();
        handler();
      }, { once:false });
    }
    bind(loginBtn, function(){ location.href = 'account.html?auth=login'; });
    bind(startBtn, function(){ location.href = 'account.html?auth=login'; });
  }catch(e){ /* noop */ }
})();
